package app.task;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;
import org.springframework.context.annotation.Scope;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

@Service
@Scope("singleton")
public class AtualizaStatusConsultaTask {
	
//	private final String URL = "http://localhost:8080/health/task/execute";
	
	private final String URL = "http://162.243.210.233:8080/health/task/execute";
	
	@Scheduled(fixedDelay = 1000000/2)
//	Task roda de 30 em 30 minutos
//	@Scheduled(fixedDelay = 1000000/30)
	public void action(){
		HttpClient client = new HttpClient();
        GetMethod method = new GetMethod(URL);
        
        try {
			client.executeMethod(method);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
}
